package com.example.ktapplication.net

import androidx.lifecycle.LiveData
import com.bumptech.glide.load.engine.Resource
import com.example.ktapplication.bean.CollectBean
import com.example.ktapplication.bean.FindArticleBean
import com.example.ktapplication.bean.HomeArticleBean
import com.example.ktapplication.bean.HomeBannerBean
import com.example.ktapplication.bean.HotSearchBean
import com.example.ktapplication.bean.LoginBean
import com.example.ktapplication.bean.LogoutBean
import com.example.ktapplication.bean.Navi
import com.example.ktapplication.bean.NavigationLeftBean
import com.example.ktapplication.bean.Project
import com.example.ktapplication.bean.RegisterBean
import com.example.ktapplication.bean.Sys
import com.example.ktapplication.bean.SysBlog
import com.example.ktapplication.bean.base.BaseRepo
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query


interface ApiService {

    @POST("user/login")
    @FormUrlEncoded
    suspend fun login(
        @Field("username") username: String,
        @Field("password") password: String
    ): LoginBean

    @POST("user/register")
    @FormUrlEncoded
    suspend fun register(
        @Field("username") username: String, @Field("password") password: String,
        @Field("repassword") repassword: String
    ): RegisterBean

    @GET("user/logout/json")
    suspend fun logout(): LogoutBean

    @GET("banner/json")
    suspend fun getHomeBanner(): HomeBannerBean

    @GET("article/list/{page}/json")
    suspend fun getArticleList(@Path("page") page: Int): HomeArticleBean

    @GET("hotkey/json")
    suspend fun getHostSearch(): HotSearchBean

    @POST("article/query/{page}/json")
    @FormUrlEncoded
    suspend fun getSearchArticles(@Path("page") page: Int,
                                  @Field("k") k: String?): FindArticleBean

    @GET("navi/json")
    suspend fun getNav(): NavigationLeftBean

    /**
     * 获取导航
     */
    @GET("navi/json")
    suspend fun getNavi(): BaseRepo<MutableList<Navi>>

    /**
     * 获取体系
     */
    @GET("tree/json")
    suspend fun getSys(): BaseRepo<MutableList<Sys>>

    /**
     * 获取体系-博客列表
     */
    @GET("article/list/0/json")
    suspend fun getSysBlogList(@Query("cid") cid: Int): BaseRepo<SysBlog>

    /**
     * 获取项目
     */
    @GET("project/tree/json")
    suspend fun getProject(): BaseRepo<MutableList<Project>>

    /**
     * 获取项目-博客列表
     */
    @GET("project/list/1/json")
    suspend fun getProjectBlogList(@Query("cid") cid: Int): BaseRepo<SysBlog>

    /**
     * 我的收藏
     */
    @GET("lg/collect/list/{page}/json")
    suspend fun getCollectionArticles(@Path("page") page: Int):CollectBean

    /**
     * 收藏文章
     */
    @POST("lg/collect/{id}/json")
    suspend fun collect(@Path("id") page: Int):BaseRepo<Any>

    /**
     * 取消收藏
     */
    @POST("lg/uncollect_originId/{id}/json")
    suspend fun unCollect(@Path("id") page: Int):BaseRepo<Any>

}